How can I find a broken row in a table

How can I find a broken row in a table

am 16.04.2010 10:22:27 von Khangelani Gama

--_000_D78A8169F9436B4DB978300336168F3B3359AFE0FESWBREXCH00u cs_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable


Please help me, I am using PostgreSQL 7.3.4 running on Redhat5

there is a table that has a broken row, but now I don't know which one is b=
roken. the table has about 20974 pages. is there a command to find this? be=
cause I used select commands like: select * from table order by column desc=
limit X ; select * from table order by column asc limit X; but as soon as =
I say select * from table; it throws out an error, saying can't read block.


Thanks in advance

Khangelani




Confidentiality Notice:http://ucs.co.za/conf.html



________________________________
The contents of and attachments to this e-mail are intended for the address=
ee only, and may contain the confidential information of UCS Group and/or i=
ts subsidiaries. Any review, use or dissemination thereof by anyone other t=
han the intended addressee is prohibited. If you are not the intended addre=
ssee please notify the writer immediately and destroy the e-mail. UCS Group=
Limited and its subsidiaries distance themselves from and accept no liabil=
ity for unauthorised use of their e-mail facilities or e-mails sent other t=
han strictly for business purposes.

--_000_D78A8169F9436B4DB978300336168F3B3359AFE0FESWBREXCH00u cs_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">

>





 


Please help me, I am using PostgreSQL 7.3.4 running =
on Redhat5


 


there is a table that has a broken row, but now I do=
n't know which one is broken. the table has about 20974 pages. is there a c=
ommand to find this? because I used select commands like:
select * from table order by column desc limit X ; select * from =
table order by column asc limit X
; but as soon as I say
select * from table; it throws out an error, saying can't read block=
..


 


family:"Courier New";
color:blue"> 


family:"Courier New";
color:blue">Thanks in advance 


family:"Courier New";
color:blue"> 


family:"Courier New";
color:blue">Khangelani


family:"Courier New";
color:blue"> 


family:"Courier New";
color:blue"> 
;Courier New";
color:black">


family:"Courier New""> 


family:"Courier New""> 


Confidentiality Notice: =3D"http://ucs.co.za/conf.html">http://ucs.co.za=
/conf.html


 


 







The contents of and attachme=
nts to this e-mail are intended for the addressee only, and may contain the=
confidential information of UCS Group and/or its subsidiaries. Any review,=
use or dissemination thereof by anyone
other than the intended addressee is prohibited. If you are not the intend=
ed addressee please notify the writer immediately and destroy the e-mail. U=
CS Group Limited and its subsidiaries distance themselves from and accept n=
o liability for unauthorised use
of their e-mail facilities or e-mails sent other than strictly for busines=
s purposes.





--_000_D78A8169F9436B4DB978300336168F3B3359AFE0FESWBREXCH00u cs_--

Re: How can I find a broken row in a table

am 16.04.2010 16:23:48 von Tom Lane

Khangelani Gama writes:
> Please help me, I am using PostgreSQL 7.3.4 running on Redhat5

> there is a table that has a broken row, but now I don't know which one
is broken. the table has about 20974 pages. is there a command to find
this?

You have to use divide-and-conquer. Try

select ctid from table limit N;

and vary N until you find the largest value that *doesn't* produce an
error. The block number in the last ctid from that query is the block
before the bad one, or possibly a small number of blocks before the bad
one if there are some totally-empty blocks.

regards, tom lane

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Re: How can I find a broken row in a table

am 16.04.2010 16:26:45 von Kevin Grittner

Khangelani Gama wrote:

> there is a table that has a broken row, but now I don't know which
> one is broken. the table has about 20974 pages.

If there are any indexes on the table which haven't been corrupted,
you might try selecting ranges of rows using one of them, capturing
the undamaged data into a new table. By subdividing damaged ranges
you can do a sort of "binary search" for the bad rows while
recovering the good ones.

-Kevin

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin